/* ==========================================================================
    Licensed under BSD 2clause license See LICENSE file for more information
    Author: Michał Łyszczek <michal.lyszczek@bofc.pl>
   ==========================================================================
         ----------------------------------------------------------
        < this simple file, deals with locking and unlocking mutex >
         ----------------------------------------------------------
                \   ^__^
                 \  (oo)\_______
                    (__)\       )\/\
                        ||----w |
                        ||     ||
   ==========================================================================
         (_)____   _____ / /__  __ ____/ /___     / __/(_)/ /___   _____
        / // __ \ / ___// // / / // __  // _ \   / /_ / // // _ \ / ___/
       / // / / // /__ / // /_/ // /_/ //  __/  / __// // //  __/(__  )
      /_//_/ /_/ \___//_/ \__,_/ \__,_/ \___/  /_/  /_//_/ \___//____/
   ========================================================================== */
#include "el-private.h"

#include <pthread.h>


/* ==========================================================================
        ____   __  __ / /_   / /(_)_____   / __/__  __ ____   _____ _____
       / __ \ / / / // __ \ / // // ___/  / /_ / / / // __ \ / ___// ___/
      / /_/ // /_/ // /_/ // // // /__   / __// /_/ // / / // /__ (__  )
     / .___/ \__,_//_.___//_//_/ \___/  /_/   \__,_//_/ /_/ \___//____/
    /_/
   ==========================================================================
    Locks mutex on specified "el" object. If mutex is not initialized, that
    is thread safety is turned off, nothing happens.
   ========================================================================== */
void el_lock
(
	struct el  *el  /* el object to lock */
)
{
	if (el->lock_initialized) pthread_mutex_lock(&el->lock);
}


/* ==========================================================================
    Unlock mutex on specified "el" object. If mutex is not initialized, that
    is thread safety is turned off, nothing happens.
   ========================================================================== */
void el_unlock
(
	struct el  *el  /* el object to unlock */
)
{
	if (el->lock_initialized) pthread_mutex_unlock(&el->lock);
}
